﻿using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Utils.Documentation;

namespace DocuGenerator
{
	internal class ElementMap
	{
		private readonly IEnumerable<DocMappingAttribute> _map;

		public ElementMap(Assembly assembly)
		{
			_map = assembly
				.GetCustomAttributes(true)
				.OfType<DocMappingAttribute>()
				.ToList();
		}

		public string GetName(string elementName)
		{
			var map = _map.FirstOrDefault(it => it.ElementName == elementName);
			return map != null ? map.DisplayName : elementName;
		}
	}
}